{-# LANGUAGE OverloadedStrings #-}

import Data.List
import Util
import Text.LaTeX
import Text.LaTeX.Base.Class
import Text.LaTeX.Base.Syntax
import Text.LaTeX.Packages.Graphicx
import Text.LaTeX.Packages.Geometry

main :: IO ()
main = printdoc doc

doc :: Monad m => LaTeXT_ m
doc = fontsize (rendertex $ Pt 12) (rendertex $ Pt 12) $ do
    mapM_ (\(y, t) -> textblock' (vw 0.5) (vh y) $ fromString t) $ zip [0.2, 0.3 .. 0.9] ["we move on", "but our", "echoes", "remain", "", "off the walls", "as we fade out", "together"]
    textblock' (vw 0.1) (vh 0.6) $ fromString $ rt 48 "reverberating"
    mapM_ (\x -> fontsize (rendertex $ Pt 12) (vw 0) $ textblock' (vw x) (vh $ x / 2) $ rotatebox' 90 $ fromString $ rt 23 "echoes") [0.6, 0.6125 .. 1.0]

rt n s = foldr (++) "" $ intersperse " " $ replicate n s

x :: LaTeXC l => Double -> Double -> l
x r t = textblock' (vw $ 0.5 + (cos t) * r) (vw $ sqrt 2 / 2 + (sin t) * r) $ rotatebox' (t * (-180) / pi - 90) $ fontsize (vw $ r * 0.20) (vw $ r * 0.25) "shadows"
